package cn.zn.modules.zzsys.cur.service.impl;

import cn.zn.framework.common.utils.PageUtils;
import cn.zn.modules.zzsys.cur.service.SysOpinionService;
import cn.zn.modules.zzsys.cur.dao.SysOpinionDao;
import cn.zn.modules.zzsys.cur.entity.SysOpinionEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;


@Service("sysOpinionService")
public class SysOpinionServiceImpl extends ServiceImpl<SysOpinionDao, SysOpinionEntity> implements SysOpinionService {

    @Override
    public PageUtils queryPage(SysOpinionEntity sysOpinion, IPage<SysOpinionEntity> page) {

        QueryWrapper<SysOpinionEntity> sysOpinionQueryWrapper = Wrappers.query();
        if (sysOpinion.getOpinionUserId() != null) {
            sysOpinionQueryWrapper.eq("opinion_user_id", sysOpinion.getOpinionUserId());
        }
        sysOpinionQueryWrapper.orderByDesc("create_time");
        IPage<SysOpinionEntity> pageResult = this.page(page, sysOpinionQueryWrapper);
        return new PageUtils(pageResult);
    }

}